﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using Zhao.IServer;
using Zhao.IServer.Field;
using Zhao.Models.AppletDto;
using Zhao.Models.Entity;
using Zhao.Repository.Base;
using Zhao.Repository.UnitOfWork;

namespace Zhao.Service.Field
{
    /// <summary>
    /// 场地类类型
    /// </summary>
    public class FieldTypesServer : BaseService<FieldTypes>, IFieldTypesServer
    {
        private readonly IUnitOfWork _unitOfWork;
        public FieldTypesServer(IBaseRepository<FieldTypes> baseDal, IUnitOfWork unitOfWork) : base(baseDal, unitOfWork)
        {
            _unitOfWork = unitOfWork;
        }

        /// <summary>
        /// 获取键值对提供下拉框使用
        /// </summary>
        /// <returns></returns>
        public async Task<List<BoxDictionary>> GetDictionariesAsync()
        {
          return await  _Client.Queryable<FieldTypes>()
                 .Where(x => x.IsDeleted != true)
                 .Select(x => new BoxDictionary
                 {
                     Id=x.FieldTypeID,
                     Value=x.FieldTypeName
                 }).ToListAsync();

        }
    }
}
